<template>
    <div>
        <div class="radio-buttons-container">
            <div v-for="type in typeList" :key="type.id">
                <div class="radio-button" @click="selectType(type.id)">
                    <input name="radio-group" :id="type.id" class="radio-button__input" type="radio">
                    <label :for="type.id" class="radio-button__label">
                        <span class="radio-button__custom"></span>

                        {{ type.name }}
                    </label>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    name: "TypesInput",
    data() {
        return {
            selectedType: 0,
            typeList: [
                { id: 0, name: "目标检测" },
                { id: 1, name: "关键点检测" },
                { id: 2, name: "ocr" },
                { id: 3, name: "线检测" }
            ]
        }
    },
    methods: {
        selectType(id) {
            this.selectedType = id
            this.$emit("selectType", this.typeList[id].name)
        },
    }
}
</script>

<style scoped>
.radio-buttons-container {
    display: flex;
    align-items: center;
    gap: 24px;
}

.radio-button {
    display: inline-block;
    position: relative;
    cursor: pointer;
}

.radio-button__input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.radio-button__label {
    display: inline-block;
    padding-left: 30px;
    margin-bottom: 10px;
    position: relative;
    font-size: 16px;
    color: #000000;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.23, 1, 0.320, 1);
}

.radio-button__custom {
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid #555;
    transition: all 0.3s cubic-bezier(0.23, 1, 0.320, 1);
}

.radio-button__input:checked+.radio-button__label .radio-button__custom {
    transform: translateY(-50%) scale(0.9);
    border: 5px solid #4c8bf5;
    color: #4c8bf5;
}

.radio-button__input:checked+.radio-button__label {
    color: #4c8bf5;
}

.radio-button__label:hover .radio-button__custom {
    transform: translateY(-50%) scale(1.2);
    border-color: #4c8bf5;
    box-shadow: 0 0 10px #4c8bf580;
}
</style>
